﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="dms.FolderPage" %>
<%@ Register TagPrefix="dms" TagName="FileList" Src="~/Controls/FileList.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderMeta" runat="server">
    <script type="text/javascript" src="../scripts/Silverlight.js"></script>
    <script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
                return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            //throw new Error(errMsg);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderContent" runat="server">
 
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h1><%= FolderInfo.Title %></h1>
    <div id="LeftCol">
        <asp:Treeview ID="fileSystemTree" runat="server" DataSourceID="dmsTreeViewSource" ExpandDepth="1">
            <NodeStyle ImageUrl="~/images/icons/folder.png" />
        </asp:Treeview>
        <asp:SiteMapDataSource ID="dmsTreeViewSource" Runat="server" SiteMapProvider="dmsMap" ShowStartingNode="false" />
    </div>
    <div id="RightCol">
        <asp:LinkButton ID="ui_btnCreate" runat="server" style="float:right; padding:0px 5px;">Create Folder</asp:LinkButton>
        <asp:PlaceHolder ID="ui_pnlRootView" runat="server" Visible="false">
            <h2>Welcome to your document management system</h2>
            Stats maybe ??
            <br />
            I'll think about what to put here.
        </asp:PlaceHolder>

        <asp:PlaceHolder ID="ui_pnlFolderView" runat="server">
            <asp:LinkButton ID="ui_btnUpload" runat="server" style="float:right; padding:0px 5px;">Add Item</asp:LinkButton>

            <h2>Files in this folder</h2>
            <dms:FileList ID="ui_lstFiles" runat="server" />

            <asp:Panel ID="ui_pnlUpload" runat="server" CssClass="dialog" style="position:relative;">
                <ajax:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="ui_btnUpload" PopupControlID="ui_pnlUpload" BackgroundCssClass="background" />
                <asp:LinkButton ID="ui_btnCancelUpload" runat="server" Text="X" style="right:2px; top:2px; position:absolute;" />
                <h2>File Upload</h2>
                <div id="silverlightControlHost">
                    <object id="MultiFileUploader" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="450" height="200">
                        <param name="source" value="../ClientBin/mpost.SilverlightMultiFileUpload.xap" />
                        <param name="onerror" value="onSilverlightError" />
                            <param name="initParams" value="MaxFileSizeKB=,MaxUploads=4,FileFilter=,ChunkSize=4194304,CustomParams=<%= FolderInfo.ID %>,DefaultColor=White" />
                        <param name="background" value="white" />
                        <param name="onload" value="pluginLoaded" />
                            <param name="minRuntimeVersion" value="4.0.50401.0" />
		                <param name="autoUpgrade" value="true" />
		                <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none">
 			                <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
		                </a>
                    </object>
                    <iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>
                </div>
                <asp:Button ID="ui_btnDone" runat="server" Text="Done" class="button" OnClick="ui_btnDone_Click" />
            </asp:Panel>
        </asp:PlaceHolder>

        <asp:Panel ID="ui_pnlCreateFolder" runat="server" CssClass="dialog">
                <ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="background" TargetControlID="ui_btnCreate" PopupControlID="ui_pnlCreateFolder" CancelControlID="ui_btnCancelFolder" />

                <h2>Create a new folder</h2>
                <asp:LinkButton ID="ui_btnCancelFolder" runat="server" style="color:Red; position:absolute; right:2px; top:2px;">X</asp:LinkButton>
                <table>
                    <tr><td>Title</td><td><asp:TextBox ID="ui_txtTitle" runat="server" /></td></tr>
                    <tr><td>Default View</td><td>
                        <asp:DropDownList ID="ui_ddlView" runat="server">
                            <asp:ListItem Text="List" />
                            <asp:ListItem Text="Thumbs" />
                            <asp:ListItem Text="Gallery" />
                        </asp:DropDownList>
                    </td></tr>
                    <tr><td></td><td><asp:Button ID="ui_btnCreateFolder" runat="server" Text="Create" OnClick="CreateFolder" style="float:right;" /></td></tr>
                </table>
            </asp:Panel>
    </div>
</asp:Content>
